package com.ftaillefer.rss.saxhandlers;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;
import org.xml.sax.SAXException;


public class RssReaderDom {


	    public void readFeed(String channelUrl) throws MalformedURLException, TransformerConfigurationException, IOException, ParserConfigurationException, SAXException, TransformerFactoryConfigurationError, TransformerException  {
	        URL url = new URL(channelUrl);
	        URLConnection conn = url.openConnection();

	        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
	        DocumentBuilder builder = factory.newDocumentBuilder();
	        Document doc = builder.parse(conn.getInputStream());
	        

	        TransformerFactory tfactory = TransformerFactory.newInstance();
	        Transformer xform = tfactory.newTransformer();

	  
	        DOMSource source = new DOMSource(doc);
	        StreamResult result = new StreamResult(System.out);
	        xform .transform(source, result);
	        
	    }
	    

	    public void readFeedUsingSAX (String channelUrl)
	    {
	    	
	    }
}
